//-----------------------------------------------------------------------
// <copyright file="CurrencyService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CurrencyService
    {
        #region Currency

        public static void CreateCurrency(Currency currency)
        {            
            try
            {
                CurrencyDAO currencyDAO = new CurrencyDAO();
                currencyDAO.CreateCurrency(currency);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateCurrencyException, ex);
            }
        }        

        public static void UpdateCurrency(Currency currency)
        {            
            try
            {
                CurrencyDAO currencyDAO = new CurrencyDAO();
                currencyDAO.UpdateCurrency(currency);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateCurrencyException, ex);
            }
        }        

        public static void DeleteCurrency(int currencyID)
        {            
            try
            {
                CurrencyDAO currencyDAO = new CurrencyDAO();
                currencyDAO.DeleteCurrency(currencyID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteCurrencyException, ex);
            }
        }
        
        public static Currency GetCurrency(int currencyID)
        {            
            try
            {
                CurrencyDAO currencyDAO = new CurrencyDAO();
                return currencyDAO.GetCurrency(currencyID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCurrencyException, ex);
            }
        }                

        public static CurrencyCollection GetCurrencies(CurrencyColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                CurrencyDAO currencyDAO = new CurrencyDAO();
                return currencyDAO.GetCurrencies(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCurrenciesException, ex);
            }
        }        

        public static CurrencyCollection GetCurrencies(CurrencyColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                CurrencyDAO currencyDAO = new CurrencyDAO();
                return currencyDAO.GetCurrencies(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCurrenciesException, ex);
            }
        }        

        #endregion
    }
}